/*
 * Copyright (c) 2012 Xilinx, Inc.  All rights reserved.
 *
 * Xilinx, Inc.
 * XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS" AS A
 * COURTESY TO YOU.  BY PROVIDING THIS DESIGN, CODE, OR INFORMATION AS
 * ONE POSSIBLE   IMPLEMENTATION OF THIS FEATURE, APPLICATION OR
 * STANDARD, XILINX IS MAKING NO REPRESENTATION THAT THIS IMPLEMENTATION
 * IS FREE FROM ANY CLAIMS OF INFRINGEMENT, AND YOU ARE RESPONSIBLE
 * FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE FOR YOUR IMPLEMENTATION.
 * XILINX EXPRESSLY DISCLAIMS ANY WARRANTY WHATSOEVER WITH RESPECT TO
 * THE ADEQUACY OF THE IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO
 * ANY WARRANTIES OR REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE
 * FROM CLAIMS OF INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY
 * AND FITNESS FOR A PARTICULAR PURPOSE.
 *
 */

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
#include "lcd.h"
#include "spi.h"

#define testsize 4096
unsigned char spi_rxdat[testsize]={0};
unsigned char spi_txdat[testsize]={0x55,0x55,0x55,0x55};

int main()
{
	//int led_pin = 960;

    //LCD_Gpio_Init();
/*
   // Address_set(0,0,240-1,240-1);
	fd = spi_init("/dev/spidev0.0",3,8,40000000);
	//int spi_init(char *spidev,int mode,int bits,int speed);
	if(fd<0){
		printf("open error \r\n");
		while(1);
	}
	printf("open successd \r\n");
    //LCD_Test();
    //LCD_Test();
	for(i=0;i<testsize/4;i++)
	{
		*(p++) = (i);
	}
	printf("data init ok \r\n");
	spi_readwrite(fd,spi_txdat,spi_rxdat,testsize);
	printf("send ok \r\n");
    for(int i=0;i<testsize/4;i++)
    {
    	printf("%08d ",p2[i]);
    	if(i%8==0)
    		printf("\r\n");
    	if(p2[i]!=(i))
    	{
    		printf("error %d \r\n",p2[i]);
    		break;
    	}

    }
    printf("test ok \r\n");// close(fd);
    */
	LCD_Gpio_Init();
	LCD_Test();
    while(1)
    {
    	//dat=0;
    	//write(gpio_bl,&dat,1);
    	//dat=1;
    	//fprintf(gpio_bl,"%c",'0');//write(gpio_bl,&dat,1);
    	LCD_Test();
    	sleep(1);
    }
   // close(fd);
/*    fclose(gpio_res);
    fclose(gpio_dc);
    fclose(p1);*/
    return 0;
}
